package com.study.hospital_3.controller;


import com.study.hospital_3.pojo.Patient;
import com.study.hospital_3.service.PatientService;
import com.study.hospital_3.vo.PatientUpdateVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/patient")
public class PatientController {
    @Resource
    private PatientService patientService;

    @GetMapping("/getPatients")
    public Map<String, Object> getPatients(Patient patient) {
        System.out.println("------------------------");
        System.out.println("patientname = " + patient.getPatientName());
        System.out.println("patientsex = " + patient.getSex());
        return patientService.getPatients(patient);
    }

    @RequestMapping("/insert")
    public Map<String, Object> insert(@RequestBody PatientUpdateVO patientUpdateVO) {
        return patientService.insert(patientUpdateVO);
    }

    @PostMapping("/deleteById")
    public Map<String, Object> deleteById(@RequestParam Integer id) {
        return patientService.deleteById(id);
    }

    @RequestMapping("/updateById")
    public Map<String, Object> updateById(@RequestBody PatientUpdateVO patientUpdateVO) {
        return patientService.updateById(patientUpdateVO);
    }
}
